import java.util.Scanner;

public class StringText {
    //输入一个字符串,统计字符串中的单词个数，这里的单词指的是连续的不是空格的字符
        public static void main(String[] args) {
            String s;
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入字符串：");
            s = scanner.nextLine();
            int count = 0;
            for ( int i = 0; i < s.length(); i++) {
                char[] ch = new char[100];
                ch[i] = s.charAt(i);
                if(ch[i] == ' '&& ch[i-1] != ' '){
                    count++;
                }
            }
            count++;
            System.out.println(count);
        }

}
